﻿<UserControl x:Class="IntexReportStudio.UserControls.EventLog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit"
    xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:fd="clr-namespace:Labs.Filtering;assembly=ReflectionStudio.Core"
    xmlns:exc="clr-namespace:ReflectionStudio.Controls"
    xmlns:events="clr-namespace:ReflectionStudio.Core.Events;assembly=ReflectionStudio.Core"
    xmlns:converters="clr-namespace:ReflectionStudio.Components.Converters;assembly=ReflectionStudio.Controls"
>
    <UserControl.Resources>
        <ObjectDataProvider x:Key="LogLevelData"
                    MethodName="GetValues" 
                    ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="events:MessageEventType" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>

    </UserControl.Resources>

    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="28" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <DockPanel Grid.Row="0">
            <StackPanel Orientation="Horizontal">
                <TextBlock VerticalAlignment="Center" Margin="5">事件:</TextBlock>
                <ComboBox Name="cbLogLevel" IsReadOnly="True" SelectedIndex="3" Margin="1"
                            ItemsSource="{Binding Source={StaticResource LogLevelData}}"
                            SelectedItem="{Binding Path=Workspace.LogLevel, Mode=TwoWay}" 
                          />
            </StackPanel>
        </DockPanel>
        <DataGrid Grid.Row="1" Name="dataGridLogEvent"
                  MaxHeight="800"
                    AutoGenerateColumns="False" EnableRowVirtualization="True"
                  VerticalScrollBarVisibility="Auto"
                  HorizontalScrollBarVisibility="Visible"
                    EnableColumnVirtualization="True" CanUserSortColumns="True">
            <!-- Column definition -->
            <DataGrid.Columns>
                <DataGridTemplateColumn Header="" Width="SizeToCells">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Source="{Binding Type, Mode=OneWay, Converter={x:Static converters:LogTypeToImageConverter.Instance}}"></Image>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn FontSize="12" Header="事件" Binding="{Binding Details, Mode=OneWay}" Width="*" />
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>
